import java.util.Arrays;
import java.util.Comparator;
import java.util.Objects;

class Money implements Cloneable{
    double money=19.9;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
class Person implements Cloneable {
    public String name;
    public int age;
    public Money m;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
        this.m=new Money();

    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        // return super.clone();
        Person tmp=(Person) super.clone();
        tmp.m=(Money) this.m.clone();
        return tmp;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}

public class Student extends Person implements Comparable<Student>{
    public String name;
    public int age;

    public Student(String name, int age) {
        super(name,age);
        this.name = name;
        this.age = age;
    }

    @Override
    public int compareTo(Student o) {
        return this.age-o.age;
    }

    //@Override
  /*  public boolean equals(Object obj) {
        if(obj==null){
            return false;
        }
        if(obj==this){
            return true;
        }
        if(!(obj instanceof Person)){
            return false;
        }
        Person person=(Person)obj;
        return this.name.equals(((Person) obj).name)&&this.age==person.age;
    }*/

    @Override
   public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return age == student.age && Objects.equals(name, student.name);
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
    /*    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }*/
    public static void  BubleSort(Comparable[]comparable){
        for (int i = 0; i < comparable.length-1; i++) {
            for (int j = 0; j <comparable.length-1-i; j++) {
                    if(comparable[j].compareTo(comparable[j+1])>0)
                    {
                        Comparable tmp=comparable[j];
                        comparable [j]=comparable[j+1];
                        comparable[j+1]=tmp;
                    }
            }
        }
        class AgeComparator implements Comparator<Student> {

            @Override
            public int compare(Student o1, Student o2) {
                return o1.age-o2.age;
            }
        }
    }
    public static void main(String[] args) {
      /*  Student student1=new Student("张三",12);
        Student student2=new Student("李四",8);
        Student student3=new Student("张三",12);
        System.out.println(student1.compareTo(student2));
        System.out.println(student1.equals(student3));*/
        Student[]students=new Student[3];
        students[0]=new Student("张三",12);
        students[1]=new Student("李四",8);
        students[2]=new Student("王五",18);
        //Arrays.sort(students);
        BubleSort(students);
        System.out.println(Arrays.toString(students));
    }
}
